-
Notifications
You must be signed in to change notification settings - Fork 473
Annotate externs from core.p4 with @corelib annotation #5285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Anton Korobeynikov <[email protected]>
|
For now only |
If there is an intention to use it in backend-specific libs, I would suggest using something like Also, unless there is something preventing an end-user/programmer from adding this annotation (which would be tricky), there is no way to really rely on these (which is why various backends might use various hacks to detect their own externs :-/). But I think this is still probably a good thing to have. |
Well, I would consider this similar to |
|
Maybe I am missing some context here. Can you explain the proposed purpose and/or advantages of adding these annotations? |
The inability to distinguish system entities from user-defined ones is a long-standing problem in the compiler. Currently, we have the hacky solution where we check the include path, but that can be ambiguous based on user-configuration. Note that files like |
|
In terms of terminology, maybe
Basically what @asl said. A concrete use case are some passes where we remove declarations, eg., p4c/frontends/p4/unusedDeclarations.cpp Line 142 in 6f6048a
We have hardcoded checks, which could be simplified if we have a policy not to remove system externs. |
IMO this is a feature, not a bug -- it should not matter where the code comes from, it should just matter what it says. The ONLY thing checking the source path (should be) done for is minimizing the debug P4 dumps when dumping IR as P4. In that case if a bunch of declarations come from the same source file, the can be replaced by a single Any other code that looks at the source file (other than for printing messages) is IMO wrong. The source file is only there for error messages and to aid debugging the compiler. |
Well, issues such as #3424 could be reverted again, which were necessary because distinguishing between persistent system methods and user-defined methods was error-prone. |
|
IMHO, there is a design flow with That being said, converting The solution in this PR is much more practical. Re @vlstill
Agree with this. |
|
So, for the name we're having:
I do not have particular preference for the name. I'd like to have the door open for backend-specific externs with similar semantics (though it would be great to distinguish between core language externs and backend-provided, my thought was to have, say |
|
My preference is to have 2 different annotations:
|
No description provided.